library(GenomicAlignments)
## Loading required package: BiocGenerics
## Loading required package: parallel
## 
## Attaching package: 'BiocGenerics'
## The following objects are masked from 'package:parallel':
## 
##     clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
##     clusterExport, clusterMap, parApply, parCapply, parLapply,
##     parLapplyLB, parRapply, parSapply, parSapplyLB
## The following objects are masked from 'package:stats':
## 
##     IQR, mad, sd, var, xtabs
## The following objects are masked from 'package:base':
## 
##     anyDuplicated, append, as.data.frame, basename, cbind, colnames,
##     dirname, do.call, duplicated, eval, evalq, Filter, Find, get, grep,
##     grepl, intersect, is.unsorted, lapply, Map, mapply, match, mget,
##     order, paste, pmax, pmax.int, pmin, pmin.int, Position, rank,
##     rbind, Reduce, rownames, sapply, setdiff, sort, table, tapply,
##     union, unique, unsplit, which, which.max, which.min
## Loading required package: S4Vectors
## Loading required package: stats4
## 
## Attaching package: 'S4Vectors'
## The following object is masked from 'package:base':
## 
##     expand.grid
## Loading required package: IRanges
## Loading required package: GenomeInfoDb
## Loading required package: GenomicRanges
## Loading required package: SummarizedExperiment
## Loading required package: Biobase
## Welcome to Bioconductor
## 
##     Vignettes contain introductory material; view with
##     'browseVignettes()'. To cite Bioconductor, see
##     'citation("Biobase")', and for packages 'citation("pkgname")'.
## Loading required package: DelayedArray
## Loading required package: matrixStats
## 
## Attaching package: 'matrixStats'
## The following objects are masked from 'package:Biobase':
## 
##     anyMissing, rowMedians
## Loading required package: BiocParallel
## 
## Attaching package: 'DelayedArray'
## The following objects are masked from 'package:matrixStats':
## 
##     colMaxs, colMins, colRanges, rowMaxs, rowMins, rowRanges
## The following objects are masked from 'package:base':
## 
##     aperm, apply, rowsum
## Loading required package: Biostrings
## Loading required package: XVector
## 
## Attaching package: 'Biostrings'
## The following object is masked from 'package:base':
## 
##     strsplit
## Loading required package: Rsamtools
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
## ✔ ggplot2 3.3.2     ✔ purrr   0.3.3
## ✔ tibble  3.1.6     ✔ dplyr   1.0.3
## ✔ tidyr   1.0.2     ✔ stringr 1.4.0
## ✔ readr   1.3.1     ✔ forcats 0.4.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::collapse()   masks Biostrings::collapse(), IRanges::collapse()
## ✖ dplyr::combine()    masks Biobase::combine(), BiocGenerics::combine()
## ✖ purrr::compact()    masks XVector::compact()
## ✖ dplyr::count()      masks matrixStats::count()
## ✖ dplyr::desc()       masks IRanges::desc()
## ✖ tidyr::expand()     masks S4Vectors::expand()
## ✖ dplyr::filter()     masks stats::filter()
## ✖ dplyr::first()      masks GenomicAlignments::first(), S4Vectors::first()
## ✖ dplyr::lag()        masks stats::lag()
## ✖ dplyr::last()       masks GenomicAlignments::last()
## ✖ ggplot2::Position() masks BiocGenerics::Position(), base::Position()
## ✖ purrr::reduce()     masks GenomicRanges::reduce(), IRanges::reduce()
## ✖ dplyr::rename()     masks S4Vectors::rename()
## ✖ purrr::simplify()   masks DelayedArray::simplify()
## ✖ dplyr::slice()      masks XVector::slice(), IRanges::slice()
library(cqn)
## Loading required package: mclust
## Package 'mclust' version 5.4.5
## Type 'citation("mclust")' for citing this R package in publications.
## 
## Attaching package: 'mclust'
## The following object is masked from 'package:purrr':
## 
##     map
## Loading required package: nor1mix
## Loading required package: preprocessCore
## Loading required package: splines
## Loading required package: quantreg
## Loading required package: SparseM
## 
## Attaching package: 'SparseM'
## The following object is masked from 'package:base':
## 
##     backsolve
library(RColorBrewer)
library(edgeR)
## Loading required package: limma
## 
## Attaching package: 'limma'
## The following object is masked from 'package:BiocGenerics':
## 
##     plotMA
library(ggplot2)
library(cowplot)
## 
## ********************************************************
## Note: As of version 1.0.0, cowplot does not change the
##   default ggplot2 theme anymore. To recover the previous
##   behavior, execute:
##   theme_set(theme_cowplot())
## ********************************************************
library(ggridges)
library(gridExtra)
## 
## Attaching package: 'gridExtra'
## The following object is masked from 'package:dplyr':
## 
##     combine
## The following object is masked from 'package:Biobase':
## 
##     combine
## The following object is masked from 'package:BiocGenerics':
## 
##     combine
colsBig <- clusterExperiment:::massivePalette

plotGCHex <- function(gr, counts){
  counts2 <- counts
  df <- as_tibble(cbind(counts2,gc=mcols(gr)$gc))
  df <- gather(df, sample, value, -gc)
  ggplot(data=df, aes(x=gc, y=log(value+1)) ) + 
    ylab("log(count + 1)") + xlab("GC-content") + 
    geom_hex(bins = 50) + theme_bw() #+ facet_wrap(~sample, nrow=2)
}
pal <- RColorBrewer::brewer.pal(n=8, "Dark2")
source("../../methods/gcqn_validated.R")
data=read.delim("../../data/rizzardi2019_GSE96614/GSE96614_flow_sorted_brain.ATAC-seq_counts.txt.gz")

# get GC content
sn <- gsub(x=data[,1], pattern="chr", replacement="")
start <- data[,2]
end <- data[,3]
gr <- GRanges(seqnames=sn, ranges=IRanges(start, end), strand="*")
ff <- FaFile("~/data/genomes/human/Homo_sapiens.GRCh37.75.dna_sm.primary_assembly.fa.gz")
peakSeqs <- getSeq(x=ff, gr)
gcContentPeaks <- letterFrequency(peakSeqs, "GC",as.prob=TRUE)[,1]
mcols(gr)$gc <- gcContentPeaks
gcGroups <- Hmisc::cut2(gcContentPeaks, g=20)
counts <- as.matrix(data[,-c(1:3)])
rownames(counts) <- 1:nrow(counts)

# get metadata
individual <- as.factor(substr(colnames(counts),2,5))
region <- as.factor(unlist(lapply(strsplit(colnames(counts), split=".", fixed=TRUE), "[[", 2)))
neuCell <- as.factor(unlist(lapply(strsplit(colnames(counts), split=".", fixed=TRUE), "[[", 3)))
table(neuCell, region, individual)
## , , individual = 5343
## 
##        region
## neuCell BA9 NA
##     neg   1  1
##     pos   1  1
## 
## , , individual = 5347
## 
##        region
## neuCell BA9 NA
##     neg   1  1
##     pos   1  1
## 
## , , individual = 5358
## 
##        region
## neuCell BA9 NA
##     neg   1  1
##     pos   1  1
## 
## , , individual = 5404
## 
##        region
## neuCell BA9 NA
##     neg   1  0
##     pos   1  0
## 
## , , individual = 5456
## 
##        region
## neuCell BA9 NA
##     neg   1  1
##     pos   1  1
## 
## , , individual = 5540
## 
##        region
## neuCell BA9 NA
##     neg   1  1
##     pos   1  1
condition <- factor(paste0(neuCell, region))
table(condition)
## condition
## negBA9  negNA posBA9  posNA 
##      6      5      6      5
design <- model.matrix(~condition+individual)

# GC content effect across entire dataset
p1 <- plotGCHex(gr, rowSums(counts)) +
  theme(axis.title = element_text(size=16)) +
  labs(fill="Nr. of peaks")
p1

Lowess fits

GC content

lowListGC <- list()
for(kk in 1:ncol(counts)){
  set.seed(kk)
  lowListGC[[kk]] <- lowess(x=gcContentPeaks, y=log1p(counts[,kk]), f=1/10)
}


for(cc in 1:nlevels(condition)){
  curCT <- levels(condition)[cc]
  id <- which(condition == curCT)
  plot(x=seq(min(gcContentPeaks), max(gcContentPeaks), length=10),
     y=seq(2, 7, length=10), type='n',
     xlab="GC-content", ylab="log(count + 1)", main=curCT)
  for(ii in 1:length(id)){
    curID <- id[ii]
    oo <- order(lowListGC[[curID]]$x)
    lines(x=lowListGC[[curID]]$x[oo], y=lowListGC[[curID]]$y[oo], col=colsBig[ii])
  }
}

Visualization

negBA9 <- lowListGC[condition == "negBA9"]
dfList <- list()
for(ss in 1:length(negBA9)){
  oox <- order(negBA9[[ss]]$x)
  dfList[[ss]] <- data.frame(x=negBA9[[ss]]$x[oox], y=negBA9[[ss]]$y[oox], sample=ss)
}
dfAll <- do.call(rbind, dfList)
dfAll$sample <- factor(dfAll$sample)

## association of GC content with counts
plotGCHex(gr, rowMeans(counts[, condition == "negBA9"])) +
  theme(axis.title = element_text(size=16)) +
  labs(fill="Nr. of peaks") + 
  geom_line(aes(x=x, y=y, group=sample, color=sample), data=dfAll, size=1) +
  scale_color_discrete()

## just the average GC content
p1 <- ggplot(dfAll, aes(x=x, y=y, group=sample, color=sample)) +
  geom_line(size = 1) +
  xlab("GC-content") +
  ylab("log(count + 1)") +
  theme_classic()
p1

# across all conditions
set.seed(44)
pList <- c()
id <- sample(nrow(counts), size=1e4)
for(cc in 1:nlevels(condition)){
  curCT <- levels(condition)[cc]
  lowCT <- lowListGC[condition == curCT]
  dfList <- list()
  for(ss in 1:length(lowCT)){
  oox <- order(lowCT[[ss]]$x[id])
  dfList[[ss]] <- data.frame(x=lowCT[[ss]]$x[id][oox], y=lowCT[[ss]]$y[id][oox], sample=ss)
  }
  dfAll <- do.call(rbind, dfList)
  dfAll$sample <- factor(dfAll$sample)
  pCT <- ggplot(dfAll, aes(x=x, y=y, group=sample, color=sample)) +
    geom_line(size = 1) +
    xlab("GC-content") +
    ylab("log(count + 1)") +
    theme_classic() +
    ggtitle(curCT) +
    theme(legend.position = "none") +
    ylim(c(3, 7))
  pList[[cc]] <- pCT
}

cowplot::plot_grid(plotlist=pList, nrow=4, ncol=4)
## Warning: Removed 9490 row(s) containing missing values (geom_path).
## Warning: Removed 1228 row(s) containing missing values (geom_path).
## Warning: Removed 9175 row(s) containing missing values (geom_path).
## Warning: Removed 28540 row(s) containing missing values (geom_path).

rm(lowListGC, lowCT, pList) ; gc()
##             used   (Mb) gc trigger   (Mb) limit (Mb)  max used   (Mb)
## Ncells   9215708  492.2   17771204  949.1         NA  17771204  949.1
## Vcells 219260982 1672.9  612884016 4676.0     102400 765032315 5836.8

Peak width

lowListWidth <- list()
for(kk in 1:ncol(counts)){
  lowListWidth[[kk]] <- lowess(x=log(width(gr)), y=log1p(counts[,kk]), f=1/10)
}

plot(x=seq(min(log(width(gr))), max(log(width(gr))), length=10),
     y=seq(0, 5, length=10), type='n',
     xlab="GC-content", ylab="log(count + 1)")
for(kk in 1:length(lowListWidth)){
  oo <- order(lowListWidth[[kk]]$x)
  lines(x=lowListWidth[[kk]]$x[oo], y=lowListWidth[[kk]]$y[oo], col=colsBig[kk])
}

# across all cell types
set.seed(44)
pList <- c()
id <- sample(nrow(counts), size=1e4)
for(cc in 1:nlevels(condition)){
  curCT <- levels(condition)[cc]
  lowCT <- lowListWidth[condition == curCT]
  dfList <- list()
  for(ss in 1:length(lowCT)){
  oox <- order(lowCT[[ss]]$x[id])
  dfList[[ss]] <- data.frame(x=lowCT[[ss]]$x[id][oox], y=lowCT[[ss]]$y[id][oox], sample=ss)
  }
  dfAll <- do.call(rbind, dfList)
  dfAll$sample <- factor(dfAll$sample)
  pCT <- ggplot(dfAll, aes(x=x, y=y, group=sample, color=sample)) +
    geom_line(size = 1) +
    xlab("Log peak width") +
    ylab("log(count + 1)") +
    theme_classic() +
    ggtitle(curCT) +
    theme(legend.position = "none") +
    ylim(c(2.5, 8.5))
  pList[[cc]] <- pCT
}

cowplot::plot_grid(plotlist=pList, nrow=4, ncol=4)
## Warning: Removed 7538 row(s) containing missing values (geom_path).
## Warning: Removed 15121 row(s) containing missing values (geom_path).

rm(lowListWidth) ; gc()
##             used   (Mb) gc trigger   (Mb) limit (Mb)  max used   (Mb)
## Ncells   9096425  485.9   17771204  949.1         NA  17771204  949.1
## Vcells 241681678 1843.9  612884016 4676.0     102400 765032315 5836.8

Mock comparisons

Note that the comparisons here aren’t mock comparisons; they compare biologically different groups.

sampleID <- condition == "negBA9"
counts <- counts[,sampleID]
set.seed(21)
mock <- factor(sample(rep(1:2, each=3)))
designMock <- model.matrix(~mock)

edgeR (TMM normalization)

## TMM normalization
library(edgeR)
d <- DGEList(counts)
d <- calcNormFactors(d)
d <- estimateDisp(d, designMock)
fit <- glmFit(d, designMock)
lrt <- glmLRT(fit, coef=2) 
dfEdgeR <- data.frame(logFC=log(2^lrt$table$logFC),
                 gc=gcGroups)
pedgeR <- ggplot(dfEdgeR) +
  aes(x=gc, y=logFC, color=gc) +
  geom_violin() +
  geom_boxplot(width=0.1) +
  scale_color_manual(values=wesanderson::wes_palette("Zissou1", nlevels(gcGroups), "continuous")) +
  geom_abline(intercept = 0, slope = 0, col="black", lty=2) +
  theme_bw() + 
  ylim(c(-1,1)) +
  ggtitle("TMM normalization") +
  xlab("GC-content bin") +
  theme(axis.text.x = element_text(angle = 45, vjust = .5),
        legend.position = "none",
        axis.title = element_text(size=16)) +
  geom_smooth(se=FALSE, color="blue", aes(group=1), lwd=1)
pedgeR
## Warning: Removed 141 rows containing non-finite values (stat_ydensity).
## Warning: Removed 141 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
## Warning: Removed 141 rows containing non-finite values (stat_smooth).

DESeq2 (MOR normalization)

## DESeq2 normalization
library(DESeq2)
dds <- DESeqDataSetFromMatrix(counts, 
                       colData=data.frame(mock=mock), 
                       design=~mock)
dds <- DESeq(dds)
## estimating size factors
## estimating dispersions
## gene-wise dispersion estimates
## mean-dispersion relationship
## final dispersion estimates
## fitting model and testing
res <- results(dds, name="mock_2_vs_1")
dfDESeq2 <- data.frame(logFC=log(2^res$log2FoldChange),
                       gc=gcGroups)
pdeseq <- ggplot(dfDESeq2) +
  aes(x=gc, y=logFC, color=gc) +
  geom_violin() +
  geom_boxplot(width=0.1) +
  scale_color_manual(values=wesanderson::wes_palette("Zissou1", nlevels(gcGroups), "continuous")) +
  geom_abline(intercept = 0, slope = 0, col="black", lty=2) +
  theme_bw() + 
  ylim(c(-1,1)) +
  ggtitle("DESeq2 MOR normalization") +
  xlab("GC-content bin") +
  theme(axis.text.x = element_text(angle = 45, vjust = .5),
        legend.position = "none",
        axis.title = element_text(size=16)) +
  geom_smooth(se=FALSE, color="blue", aes(group=1), lwd=1)
pdeseq
## Warning: Removed 145 rows containing non-finite values (stat_ydensity).
## Warning: Removed 145 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
## Warning: Removed 145 rows containing non-finite values (stat_smooth).

Full quantile

## Full quantile normalization
countsFQ <- FQnorm(counts, type="median")
d <- DGEList(countsFQ)
d <- estimateDisp(d, designMock)
fit <- glmFit(d, designMock)
lrtFQ <- glmLRT(fit, coef=2)
dfFQ <- data.frame(logFC=log(2^lrtFQ$table$logFC),
                      gc=gcGroups)
pFQ <- ggplot(dfFQ) +
  aes(x=gc, y=logFC, color=gc) +
  geom_violin() +
  geom_boxplot(width=0.1) +
  scale_color_manual(values=wesanderson::wes_palette("Zissou1", nlevels(gcGroups), "continuous")) +
  geom_abline(intercept = 0, slope = 0, col="black", lty=2) +
  theme_bw() + 
  ylim(c(-1,1)) +
  ggtitle("FQ normalization") +
  xlab("GC-content bin") +
  theme(axis.text.x = element_text(angle = 45, vjust = .5),
        legend.position = "none",
        axis.title = element_text(size=16)) +
  geom_smooth(se=FALSE, color="blue", aes(group=1), lwd=1)
pFQ
## Warning: Removed 139 rows containing non-finite values (stat_ydensity).
## Warning: Removed 139 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
## Warning: Removed 139 rows containing non-finite values (stat_smooth).

Composite plot for figure 1

p <- plot_grid(p1 + ggtitle("negBA9 cells"), 
               pedgeR, 
               pdeseq, 
               pFQ,
               labels=letters[1:4])
## Warning: Removed 141 rows containing non-finite values (stat_ydensity).
## Warning: Removed 141 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
## Warning: Removed 141 rows containing non-finite values (stat_smooth).
## Warning: Removed 145 rows containing non-finite values (stat_ydensity).
## Warning: Removed 145 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
## Warning: Removed 145 rows containing non-finite values (stat_smooth).
## Warning: Removed 139 rows containing non-finite values (stat_ydensity).
## Warning: Removed 139 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
## Warning: Removed 139 rows containing non-finite values (stat_smooth).
p

ggsave("~/Dropbox/research/atacseq/bulk/plots/figure1_rizzardi.png",
       units="in", width=12, height=9)

Figure 2

## cqn
cqnModel <- cqn(counts, x=gcContentPeaks, sizeFactors = colSums(counts), lengthMethod="fixed", lengths = 1000)
## Warning: The use of 'sig2' is deprecated; do specify 'sigma' (= sqrt(sig2))
## instead
d <- DGEList(counts)
d$offset <- cqnModel$glm.offset
d <- estimateDisp(d, designMock)
fit <- glmFit(d, designMock)
lrtCqn <- glmLRT(fit, coef=2)
dfCqn <- data.frame(logFC=log(2^lrtCqn$table$logFC),
                   gc=gcGroups)
pCqn <- ggplot(dfCqn) +
  aes(x=gc, y=logFC, color=gc) +
  geom_violin() +
  geom_boxplot(width=0.1) +
  scale_color_manual(values=wesanderson::wes_palette("Zissou1", nlevels(gcGroups), "continuous")) +
  geom_abline(intercept = 0, slope = 0, col="black", lty=2) +
  theme_bw() + 
  ylim(c(-1,1)) +
  xlab("GC-content bin") +
  ggtitle("cqn normalization") +
  theme(axis.text.x = element_text(angle = 45, vjust = .5),
        legend.position = "none",
        axis.title = element_text(size=16)) +
  geom_smooth(se=FALSE, color="blue", aes(group=1), lwd=1)
pCqn
## Warning: Removed 344 rows containing non-finite values (stat_ydensity).
## Warning: Removed 344 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
## Warning: Removed 344 rows containing non-finite values (stat_smooth).

# ## EDASeq
library(EDASeq)
## Loading required package: ShortRead
## 
## Attaching package: 'ShortRead'
## The following object is masked from 'package:dplyr':
## 
##     id
## The following object is masked from 'package:purrr':
## 
##     compose
## The following object is masked from 'package:tibble':
## 
##     view
#emptyRows <- which(rownames(counts) == "")
#rownames(counts)[emptyRows] <- paste0("emptyPeak",1:length(emptyRows))
dataWithin <- withinLaneNormalization(counts, y=gcContentPeaks,
                                      num.bins=20, which="full")
dataNorm <- betweenLaneNormalization(dataWithin, which="full")
d <- DGEList(dataNorm)
d <- estimateDisp(d, designMock)
## Warning: Zero sample variances detected, have been offset away from zero
fit <- glmFit(d, designMock)
lrtEDASeq <- glmLRT(fit, coef=2)
dfEDASeq <- data.frame(logFC=log(2^lrtEDASeq$table$logFC),
                    gc=gcGroups)
pEDASeq <- ggplot(dfEDASeq) +
  aes(x=gc, y=logFC, color=gc) +
  geom_violin() +
  geom_boxplot(width=0.1) +
  scale_color_manual(values=wesanderson::wes_palette("Zissou1", nlevels(gcGroups), "continuous")) +
  geom_abline(intercept = 0, slope = 0, col="black", lty=2) +
  theme_bw() +
  ylim(c(-1,1)) +
  xlab("GC-content bin") +
  ggtitle("FQ-FQ normalization") +
  theme(axis.text.x = element_text(angle = 45, vjust = .5),
        legend.position = "none",
        axis.title = element_text(size=16)) +
  geom_smooth(se=FALSE, color="blue", aes(group=1), lwd=1)


## GC-QN
countsGCQN <- gcqn(counts, gcGroups, summary = "median")
d <- DGEList(countsGCQN)
d <- estimateDisp(d, designMock)
fit <- glmFit(d, designMock)
lrtGCQN <- glmLRT(fit, coef=2)
dfGCQN <- data.frame(logFC=log(2^lrtGCQN$table$logFC),
                   gc=gcGroups)
pGCQN <- ggplot(dfGCQN) +
  aes(x=gc, y=logFC, color=gc) +
  geom_violin() +
  geom_boxplot(width=0.1) +
  scale_color_manual(values=wesanderson::wes_palette("Zissou1", nlevels(gcGroups), "continuous")) +
  geom_abline(intercept = 0, slope = 0, col="black", lty=2) +
  theme_bw() + 
  ylim(c(-1,1)) +
  xlab("GC-content bin") +
  ggtitle("GC-FQ normalization") +
  theme(axis.text.x = element_text(angle = 45, vjust = .5),
        legend.position = "none",
        axis.title = element_text(size=16)) +
  geom_smooth(se=FALSE, color="blue", aes(group=1), lwd=1)

## ridges plot 
countsN <- counts[,1:3]
gcGroups10 <- Hmisc::cut2(gcContentPeaks, g=10)

lc <- log1p(c(countsN))
joyDat <- data.frame(lc=lc, 
                     gc=rep(gcGroups10, 3),
                     sample=rep(1:3, each=nrow(countsN)))
axText <- 0
pRidge1 <- joyDat %>% ggplot(aes(y=gc)) + 
  geom_density_ridges(aes(x=lc), bandwidth = 0.1) + 
  facet_wrap(.~sample, nrow=1) +
  theme_ridges(grid=FALSE, font_size=5, center_axis_labels = TRUE) + 
  xlim(c(1.5,9)) +
  xlab("log(count + 1)") +
  ylab("GC-content bin") +
  theme(axis.text.y = element_text(size=axText),
        axis.text.x = element_text(size=10),
        legend.position = "none",
        axis.title = element_text(size=16), 
             strip.background = element_blank(),
             strip.text.x = element_blank())

pFC <- cowplot::plot_grid(pCqn, pEDASeq, pGCQN,
                          labels=letters[2:4],
                          nrow=3, ncol=1)
## Warning: Removed 344 rows containing non-finite values (stat_ydensity).

## Warning: Removed 344 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
## Warning: Removed 344 rows containing non-finite values (stat_smooth).
## Warning: Removed 198 rows containing non-finite values (stat_ydensity).
## Warning: Removed 198 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
## Warning: Removed 198 rows containing non-finite values (stat_smooth).
## Warning: Removed 159 rows containing non-finite values (stat_ydensity).
## Warning: Removed 159 rows containing non-finite values (stat_boxplot).
## `geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
## Warning: Removed 159 rows containing non-finite values (stat_smooth).
pFig2 <- cowplot::plot_grid(pRidge1, 
                   pFC,
                   labels=c("a",""))
## Warning: Removed 27139 rows containing non-finite values (stat_density_ridges).
pFig2

ggsave("~/Dropbox/research/atacseq/bulk/plots/figure2_rizzardi.png",
       units="in", width=12, height=9)